
function xDef()
{
    if (typeof(arguments) == "undefined")
        return false;
    for(var i = 0; i < arguments.length; ++i)
    {
        if( typeof(arguments[i]) == "undefined")
            return false;
    }
    return true;
}
 
function arrIndexOf(arr, value)
{
    for (var i = 0; i < arr.length; i++)
    {
        if (arr[i] == value) {
            return i;
        }
    }
    return -1;
}

function arrContainsKey(arr, key)
{
    return !!arr[key];
}

function arrContainsValue(arr, value)
{
    return arrIndexOf(arr, value) != -1;
}

function copyObject(src, dst)
{
    for (var i in src)
        dst[i] = src[i];
}

function forEach(arr, callback, thisObject)
{
//    for (var i1 = 0, i2 = arr.length; i < i2; i++) {
    for (var i in arr) {
        callback.call(thisObject, arr[i], i, arr);
    }
}

/**
 * Extends one class with another. Gives ability to access properties and
 * methods of the superclass having the same names as in subclass.
 *
 * Should be used as follows:
 *
 * // Define SuperClass and its methods
 * SuperClass = function(objArgs) {
 *   ...
 * };
 *
 * SuperClass.prototype.init = function(objArgs) {
 *   ...
 * };
 *
 * // Define SubClass and its methods
 * SubClass = function(objArgs) {
 *   ...
 *   // Call constructor of superclass
 *   SubClass.SUPERconstructor.call(this, objArgs);
 *   ...
 * };
 *
 * // Inherit SuperClass
 * inherit(SubClass, SuperClass);
 *
 * SubClass.prototype.init = function(objArgs) {
 *   ...
 *   // Call method of superclass
 *   SubClass.SUPERclass.init.call(this, objArgs);
 *   ...
 * };
 *
 * @param {object} objSubClass Inheriting class
 * @param {object} objSuperClass Class from which to inherit
 */
function inherit(objSubClass, objSuperClass) {
    // Duplicate prototype of superclass
    var Inheritance = function() {};
    Inheritance.prototype = objSuperClass.prototype;
    objSubClass.prototype = new Inheritance();
    // Fix constructor property to point to the self constructor because it is
    // pointing to the nested Inheritance function
    objSubClass.prototype.constructor = objSubClass;
    // Reference to constructor of superclass to be able to invoke it
    objSubClass.SUPERconstructor = objSuperClass;
    // Reference to prototype of superclass to be able to invoke its methods
    objSubClass.SUPERclass = objSuperClass.prototype;
}

function getCookie(name) {
    return Zapatec.Utils.getCookie(name);
}